﻿
@{
    Layout = "~/Areas/Web/Views/Shared/_UserCenter.cshtml";
    ViewBag.Title = "支付密码";
}
<div class="box1 lh24" id="step1" name="stepname">
    <div class="title bot-border">
        <h3 class="title_txt cur">提现支付密码设置</h3>
    </div>
    <div class="border-box">
        <div class="user-set userset-lcol">
            <div class="form">
                <div class="item">
                    <span class="label">请设置密码：</span>
                    <div class="fl">
                        <input type="password" value="" id="new" name="userVo.realName" maxlength="20" class="itxt fl">
                        <span id="new_msg" class="prompt-06" style="padding-left:10px;"></span><span>6-20位字符，可使用字母、数字或符号的组合</span>
                    </div>
                </div>
                <div class="item">
                    <span class="label">请确认密码：</span>
                    <div class="fl">
                        <input type="password" value="" id="confirm" name="userVo.realName" maxlength="20" class="itxt fl">
                        <span class="prompt-06" id="confirm_msg" style="padding-left:10px;"></span>
                    </div>
                </div>
                <div class="item">
                    <span class="label">&nbsp;</span>
                    <div class="fl">
                        <a id="submitPwd" class="btn-5" href="javascript:;">提交</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        $('#new').blur(function () {
            var d = $(this).val();
            if (d.length < 6) {
                $('#new').css({ borderColor: '#f60' });
                $('#new_msg').css({ color: '#f60' }).html('密码不能少于6位!');
                stae2 = '';
            } else {
                $('#new').css({ borderColor: '#ccc' });
                $('#new_msg').css({ color: '#ccc' }).html('');
                stae2 = d;
                if ($('#confirm').val() != '' && $('#confirm').val() == $('#new').val()) {
                    $('#confirm').css({ borderColor: '#ccc' });
                    $('#confirm_msg').css({ color: '#ccc' }).html('');
                    stae3 = d;
                }
            }
        });
        $('#confirm').blur(function () {
            var d = $(this).val();
            if (d == $('#new').val()) {
                $('#confirm').css({ borderColor: '#ccc' });
                $('#confirm_msg').css({ color: '#ccc' }).html('');
                stae3 = d;
            } else {
                $('#confirm').css({ borderColor: '#f60' });
                $('#confirm_msg').css({ color: '#f60' }).html('两次密码不一致!');
                stae3 = '';
            }
        });
        $('#submitPwd').bind('click', function () {
            //console.log(stae1)
            if (!stae2) {
                $('#new').css({ borderColor: '#f60' });
                $('#new_msg').css({ color: '#f60' }).html('密码不能少于6位!');
            }
            if (!stae3) {
                $('#confirm').css({ borderColor: '#f60' });
                $('#confirm_msg').css({ color: '#f60' }).html('两次密码不一致!');
            }
            if (stae2 && stae3) {
                var loading = showLoading();
                $.ajax({
                    type: 'post',
                    url: '@Url.Action("SavePayPwd")',
                    data: { "pwd": stae3 },
                    dataType: "json",
                    success: function (data) {
                        loading.close();
                        if (data.success) {
                            $.dialog.succeedTips('设置成功！');
                            window.top.close();
                        }
                    }
                });
            }
        });
    });
</script>